package com.windward.vii.service;

import com.windward.vii.common.JsonResult;
import com.windward.vii.dao.entity.AppBanner;
import com.windward.vii.dao.mapper.AppBannerMapper;
import com.windward.vii.domain.banner.BannerVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Component
public class AppBannerService {

    @Resource
    AppBannerMapper appBannerMapper;

    public List<BannerVO> getRecommendBanner() {
        List<AppBanner> list = appBannerMapper.getRecommendBanner();
        List<BannerVO> bannerList = new ArrayList<>();
        if(list != null && list.size() > 0) {
            for(AppBanner banner : list) {
                BannerVO bannerVO = new BannerVO();
                BeanUtils.copyProperties(banner, bannerVO);
                bannerList.add(bannerVO);
            }
        }
        return bannerList;
    }

    public List<BannerVO> getNewestBanner() {
        List<AppBanner> list = appBannerMapper.getNewestBanner();
        List<BannerVO> bannerList = new ArrayList<>();
        if(list != null && list.size() > 0) {
            for(AppBanner banner : list) {
                BannerVO bannerVO = new BannerVO();
                BeanUtils.copyProperties(banner, bannerVO);
                bannerList.add(bannerVO);
            }
        }
        return bannerList;
    }
}
